//
// Created by WangPeng on 24-8-16.
//

#ifndef RTSP_H264_SERVER_H264_FILE_H
#define RTSP_H264_SERVER_H264_FILE_H

#include <cstdint>
#include "abstract_interface.h"

class CH264File : public CAbstractInterface
{
public:
    explicit CH264File(std::string file_name);
    ~CH264File() override;
    long get_frame_data(char *&frame, long size) override;
    void play(CUdpSocket* udp_socket, CRtpProtocol* rtp_protocol) override;
private:
    static int start_code3(const char* buf);
    static int start_code4(const char* buf);
    static char* find_next_start_code(char* buf, long len);
    static int send_rtp_payload_over_udp(CUdpSocket *udp_socket, CRtpProtocol* rtp_protocol, char *frame, std::size_t frame_size);
};

#endif //RTSP_H264_SERVER_H264_FILE_H
